home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / flmgmtcl.zip / FILE.H < prev    next >
C/C++ Source or Header  |  1995-11-02  |  7KB  |  225 lines

  1. // ==========================================================================
  2. //                             Class Specification : CFileSpec
  3. // ==========================================================================
  4.  
  5. // Header file : file.h
  6.  
  7. // Source : Periphere NV (R.Mortelmans)
  8. // Creation Date :        2nd November. 1995
  9. // Last Modification : 2nd November. 1995
  10.                           
  11. // //////////////////////////////////////////////////////////////////////////
  12.  
  13. // Properties:
  14. //    NO    Abstract class (does not have any objects)
  15. //    YES    Derived from CObject
  16.  
  17. //    NO    Is a Cwnd.                     
  18. //    NO    Two stage creation (constructor & Create())
  19. //    NO    Has a message map
  20. //    NO Needs a resource (template)
  21.  
  22. //    NO    Persistent objects (saveable on disk)      
  23. //    NO    Uses exceptions
  24.  
  25. // //////////////////////////////////////////////////////////////////////////
  26.  
  27. // Desciption :         
  28. //        This class encapsulates a file specification.
  29. //        A file specification consists of a fule base name, a file extender
  30. //        and file attributes (length, ...)
  31.  
  32. // Remark:
  33. //        File specifications are always represented in lower case characters
  34. //         An implicite conversion is done when the supplied names are in upper case;
  35. //        All member functions starting with "Do" will physically change something
  36. //         on disk.  Other functions only change the internal data.
  37.  
  38. // Prerequisites (necessary conditions):
  39. //        
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. #ifndef __FILE_H__
  43. #define __FILE_H__
  44.  
  45. class CFileSpec : public CObject
  46. {
  47. DECLARE_DYNAMIC(CFileSpec)
  48.  
  49. // Data members -------------------------------------------------------------
  50. public:
  51.     
  52. protected:
  53.     CString             m_sFileName;
  54.     CTime                m_time;
  55.     LONG                m_lnLength;
  56.     BYTE                 m_eAttributes;
  57.  
  58. private:
  59.     
  60. // Member functions ---------------------------------------------------------
  61. public:
  62.     CFileSpec();
  63.     // --- In  :
  64.     // --- Out : 
  65.     // --- Returns :
  66.     // --- Effect : Contructor of object
  67.     //                It will initialize the internal state
  68.  
  69.     CFileSpec(const char* pszFileName);
  70.     // --- In  : pszFileName : The new file name of the object
  71.     // --- Out : 
  72.     // --- Returns : 
  73.     // --- Effect : 
  74.     // --- Effect : Contruction of an object together with a SetFileName()
  75.     //                Notice that whether the file specification is valid or not
  76.     //                cannot be checked in this way
  77.     
  78.     CFileSpec(const CFileSpec& fileSrc);
  79.     // --- In :    fileSrc : File object which will be copied
  80.     // --- Out : 
  81.     // --- Returns :
  82.     // --- Effect : Copy contruction.
  83.     
  84.     const CFileSpec& operator=(const CFileSpec& fileSrc);
  85.     // --- In :    fileSrc : File object which will be assign to 'this' file object
  86.     // --- Out:
  87.     // --- Returns: 
  88.     // --- Effect : Assignment operator
  89.     
  90.     CString GetBaseName() const;
  91.     // --- In  :
  92.     // --- Out : 
  93.     // --- Returns :The base name of this object
  94.     //                 It does not end in a full stop
  95.     // --- Effect : 
  96.     BOOL SetBaseName(const char* pszBaseName);
  97.     // --- In  : pszBaseName : The new base name of the object
  98.     // --- Out : 
  99.     // --- Returns : Whether base name has a correct format
  100.     //                 Wild characters are allowed
  101.     // --- Effect : 
  102.     void ForceSetBaseName(const char* pszBaseName);
  103.     // --- In  : pszBaseName : The new base name of the object
  104.     // --- Out : 
  105.     // --- Returns : 
  106.     // --- Effect : This function extracts illegal characters and thus
  107.     //                will always succeeds
  108.     
  109.     CString GetExtender() const;
  110.     // --- In  :
  111.     // --- Out : 
  112.     // --- Returns :The extender of this object
  113.     //                 It never begins with a full stop
  114.     //                 The result may be an empty string
  115.     // --- Effect : 
  116.     BOOL SetExtender(const char* sExtender);
  117.     // --- In  : pszExtender : The new extender of the object
  118.     // --- Out : 
  119.     // --- Returns : Whether extender has a correct format
  120.     //                 Wild characters are allowed
  121.     // --- Effect : 
  122.     void ForceSetExtender(const char* sExtender);
  123.     // --- In  : pszExtender : The new extender of the object
  124.     // --- Out : 
  125.     // --- Returns : 
  126.     // --- Effect : This function extracts illegal characters and thus
  127.     //                will always succeeds
  128.     
  129.     CString GetFileName() const;
  130.     // --- In  :
  131.     // --- Out : 
  132.     // --- Returns :The base name and the extender of this object
  133.     //                 The result may be an empty string
  134.     // --- Effect : 
  135.     BOOL SetFileName(const char* sFileName);
  136.     // --- In  : pszFileName : The new base name and extender of the object
  137.     // --- Out : 
  138.     // --- Returns : Whether file name has a correct format
  139.     //                 Wild characters are allowed
  140.     // --- Effect :                           
  141.     void ForceSetFileName(const char* sFileName);
  142.     // --- In  : pszFileName : The new base name and extender of the object
  143.     // --- Out : 
  144.     // --- Returns : 
  145.     // --- Effect : This function extracts illegal characters and thus
  146.     //                will always succeeds
  147.     
  148.     CTime GetTime() const;
  149.     // --- In  :
  150.     // --- Out : 
  151.     // --- Returns :The creation date and time of this object
  152.     // --- Effect : 
  153.     BOOL SetTime(CTime time);
  154.     // --- In  : time : The new date and time of the object
  155.     // --- Out : 
  156.     // --- Returns : Whether date and time specification is valid
  157.     // --- Effect : Notice that the DOS file system can only work with
  158.     //                even numbered seconds (12 seconds exist, 13 not)
  159.     //                DOS will automatically convert this
  160.     
  161.     LONG GetLength() const;
  162.     // --- In  :
  163.     // --- Out : 
  164.     // --- Returns :The file length in bytes of this object
  165.     // --- Effect : 
  166.     BOOL SetLength(LONG lnLength);
  167.     // --- In  : lnLength : The length of the object
  168.     // --- Out : 
  169.     // --- Returns : Whether length specification is valid
  170.     // --- Effect :                           
  171.     
  172.     BYTE GetAttributes() const;
  173.     // --- In  :
  174.     // --- Out : 
  175.     // --- Returns :The file attributes of this object
  176.     // --- Effect : 
  177.     BOOL SetAttributes(CFile::Attribute attributes);
  178.     // --- In  : atrributes : The attributes of the object
  179.     // --- Out : 
  180.     // --- Returns : Whether attributes specification is valid
  181.     // --- Effect :                           
  182.  
  183.     BOOL IsEmpty() const;
  184.     // --- In  : 
  185.     // --- Out : 
  186.     // --- Returns : Whether the file specification is empty
  187.     // --- Effect : 
  188.  
  189.     void Empty();
  190.     // --- In  : 
  191.     // --- Out : 
  192.     // --- Returns : 
  193.     // --- Effect : Clears the file specification
  194.     
  195.     BOOL operator==(CFileSpec fileSpec) const;
  196.     BOOL operator!=(CFileSpec fileSpec) const;
  197.     BOOL operator<=(CFileSpec fileSpec) const;
  198.     BOOL operator<(CFileSpec fileSpec) const;
  199.     BOOL operator>=(CFileSpec fileSpec) const;
  200.     BOOL operator>(CFileSpec fileSpec) const;
  201.     // --- In  : fileSpec : Second object to which this object will be compared
  202.     // --- Out : 
  203.     // --- Returns : FALSE or TRUE
  204.     // --- Effect : Comparison operators
  205.     
  206. #ifdef _DEBUG
  207.     virtual void Dump(CDumpContext&) const;
  208.     virtual void AssertValid() const;
  209. #endif //_DEBUG
  210.  
  211.     virtual ~CFileSpec();
  212.     // --- In  :
  213.     // --- Out : 
  214.     // --- Returns :
  215.     // --- Effect : Destructor of object
  216.  
  217. protected:      
  218.  
  219. private:
  220.                    
  221. };
  222.  
  223. #endif
  224. // ==========================================================================
  225.